package com.zhida.jiyangcenter.mian

import android.os.Bundle
import androidx.lifecycle.lifecycleScope
import chooongg.base.annotation.ContentLayout
import chooongg.base.annotation.TitleBar
import chooongg.base.utils.tipFail
import chooongg.http.APIException
import com.zhida.jiyangcenter.R
import com.zhida.jiyangcenter.api.APIHealth
import com.zhida.jiyangcenter.api.BaseAPI
import com.zhida.jiyangcenter.api.ManagementInfoEntity
import com.zhida.jiyangcenter.utils.request
import kotlinx.android.synthetic.main.activity_archives_details.*

@TitleBar(false)
@ContentLayout(R.layout.activity_archives_details)
class ArchivesDetailsActivity:BaseActivity() {
    override fun initConfig(savedInstanceState: Bundle?) {
        title_bar.title("管理方案").navigationIcon(R.drawable.iv_back_fill){
            finish()
        }
        getData()
    }

    private fun getData() {
        lifecycleScope.request({APIHealth.service().managementInfo(intent.getStringExtra("uuid")?:"")},object :BaseAPI<ManagementInfoEntity>(){
            override fun onSuccess(t: ManagementInfoEntity?, state: Int, msg: String) {
                var s=t?.content+"\n\n\n"
                t?.scheme_serve?.forEach {
                    s+=it.name+"  x"+it.num+"\n"
                }
                t?.scheme_product?.forEach {
                    s+=it.name+"  x"+it.num+"\n"
                }
                tv_content.text=s
            }

            override fun onError(e: APIException) {
                tipFail(e.eMessage)
            }

        })
    }
}